package com.ssl.rms.shiro;

import org.apache.shiro.web.servlet.NameableFilter;

/**
 * 描述：自定义登录时候生成的token对象
 *
 * @author ssl
 * @create 2018/02/07 15:35
 */
public class UsernamePasswordToken extends org.apache.shiro.authc.UsernamePasswordToken {
    private static final long serialVersionUID = 1L;

    /**
     * 验证码
     */
    private String captcha;
    /**
     * 当前filter的名称
     */
    private NameableFilter loginFilter;

    public UsernamePasswordToken() {
        super();
    }

    /**
     * 生成登录时候的令牌
     *
     * @param username    用户名
     * @param password    密码
     * @param remberMe    是否记住我
     * @param host        登录的ip
     * @param captcha     验证码
     * @param loginFilter 匹配的过滤器名称：该名称可以用在realm的认证回调函数doGetAuthenticationInfo中，判断当前登录使用哪种验证方式（即哪个filter控制用户登录）,
     *                    然后用不同的校验方式。
     */
    public UsernamePasswordToken(String username, char[] password, boolean remberMe, String host, String captcha,
                                 NameableFilter loginFilter) {
        super(username, password, remberMe, host);
        this.captcha = captcha;
        this.loginFilter = loginFilter;
    }

    public String getCaptcha() {
        return captcha;
    }

    public void setCaptcha(String captcha) {
        this.captcha = captcha;
    }

    public NameableFilter getLoginFilter() {
        return loginFilter;
    }

    public void setLoginFilter(NameableFilter loginFilter) {
        this.loginFilter = loginFilter;
    }
}
